

import axios from 'axios';
import {warnLog} from "./log";

export function async_loadText(filepath:string){
    return new Promise((resolve, reject) => {
        axios.get('assets/ball.obj').then((res)=>{
            resolve(res.data);
        }).catch((e)=>{
            warnLog(`load filepath:${filepath} error!`);
            reject(e)
        });
    });
}


export function async_loadImage(filepath:string){
    return new Promise((resolve, reject) => {
        let img = new Image();
        img.src = filepath;
        img.onerror = function (){
            warnLog(`load filepath:${filepath} error!`);
            reject(`load filepath:${filepath} error!`);
        }
        img.onload = function (){
            resolve(img);
        }
    })
}
